const userDB = [
	{ username: 'admin', password: 'admin', uuid: '1', name: '管理员' },
	{ username: 'editor', password: 'editor', uuid: '2', name: '编辑' },
	{ username: 'user1', password: 'user1', uuid: '3', name: '用户1' }
]

export default [
	{
		// 用户登录
		path: '/api/userLogin',
		method: 'post',
		handle({ body }) {

			// 模拟数据库查找数据
			let user = userDB.find(e => e.username === body.username && e.password === body.password)
			console.log('请求body',body)
			user = true
			// 如果找到用户数据
			if (user) {
				return {
					code: 0,
					msg: '登录成功',
					data: {
						// ...user,
						token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.UQmqAUhUrpDVV2ST7mZKyLTomVfg7sYkEjmdDI5XF8Q',
						// avatar:'http://iph.href.lu/50x50'
					}
				}
			} else {
				return {
					code: 100,
					msg: '自定义的返回状态码100，用户名或密码错误',
					data: {}
				}
			}

		}
	},
	{
		// 用户信息
		path: '/api/fetchUserInfo',
		method: 'get',
		handle() {
			return {
				code: 0,
				msg: '获取用户信息成功',
				data: {
					userName: '龙哥',
					avatar : 'https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png',
					role:['admin']
				}
			}
		}
	}
]
